package se.zens.demo.wsapp.implementation;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Currency;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

import se.zens.demo.wsapp.configuration.WSAppConfiguration;
import se.zens.demo.wsapp.implementation.exchangerates.AddExchangeRateProcessor;
import se.zens.demo.wsapp.implementation.exchangerates.ConvertAmountProcessor;
import se.zens.demo.wsapp.implementation.exchangerates.GetExchangeRateProcessor;
import se.zens.demo.wsapp.interfaces.ExchangeRatesService;
import se.zens.demo.wsapp.interfaces.model.AddExchangeRateRequest;
import se.zens.demo.wsapp.interfaces.model.AddExchangeRateRessponse;
import se.zens.demo.wsapp.interfaces.model.ConvertAmountRequest;
import se.zens.demo.wsapp.interfaces.model.ConvertAmountResponse;
import se.zens.demo.wsapp.interfaces.model.ExchangeRate;
import se.zens.demo.wsapp.interfaces.model.GetExchangeRateRequest;
import se.zens.demo.wsapp.interfaces.model.GetExchangeRateRessponse;

@WebService

public class ExchangeRatesServiceImpl implements ExchangeRatesService
{

	private  Map<String,ExchangeRate> currentExchangeRates;
	
	private WSAppConfiguration config;
	
	public ExchangeRatesServiceImpl(WSAppConfiguration config)
	{
		this();
		this.config = config;
	}
	
	public ExchangeRatesServiceImpl()
	{
		currentExchangeRates = new HashMap<String,ExchangeRate>();
		
	}
	
	public ConvertAmountResponse convertAmount( ConvertAmountRequest request)
	{
		ConvertAmountProcessor processor  = new ConvertAmountProcessor(config, request, currentExchangeRates);
		processor.process();
		return processor.getResponse();
	}

	public GetExchangeRateRessponse getExchangeRate(
			GetExchangeRateRequest request)
	{
		GetExchangeRateProcessor processor  = new GetExchangeRateProcessor(config, request, currentExchangeRates);
		processor.process();
		return processor.getResponse();
	}

	public AddExchangeRateRessponse addExchangeRate(AddExchangeRateRequest request)
	{
		AddExchangeRateProcessor processor  = new AddExchangeRateProcessor(config, request, currentExchangeRates);
		processor.process();
		return processor.getResponse();
	}
	
	

}
